coos.extend(Array.prototype,{
	clear : function () 
	{
		this.length = 0;
		return this;
	},
	first : function () 
	{
		return this[0];
	},
	last : function () 
	{
		return this[this.length - 1];
	},
	size : function () 
	{
		return this.length;
	},
	contains : function (value) 
	{
		for(var i in this)
		{
			if(this[i] == value)  return true;
		}
		return false;
	},
	append : function(value) 
	{
		this.push(value);
		return this;
	},
	remove: function(value) 
	{
		for(var i in this)
		{
			if(this[i] == value)
			{
				this.splice(i,1);
			}
		}
		return this;
	},
	random : function(min, max)
	{
		if(min && max)
		{
			return this[Math.floor(Math.random() * (max - min + 1) + min)] || null;
		}
		else
		{
			return this[Math.floor(Math.random() * this.length)] || null;
		}
	},
	copy : function(value) 
	{
	    var temp = [];
		for(var i in this)
		{
			temp[i] = this[i];
		}
		return temp;
	},
	compare : function(arr)
	{
		for(var i in arr)
		{
			if(!this.contains(arr[i])) return false;
		}
		for(var j in this)
		{
			if(!arr.contains(this[j])) return false;
		}
		return true;
	},
	indexOf : function(item, from)
	{
		var len = this.length;
		for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++)
		{
			if (this[i] === item) 
			{
				return i;
			}
		}
		return -1;
	},
	lastIndexOf : function (item, from) 
	{
		var len = this.length;
		for (var i = (from < len) ? Math.max(0, len - from) : len || 0; i > -1; i--)
		{
			if (this[i] === item) 
			{
				return i;
			}
		}
		return -1;
	},
	count : function () 
	{
		var count = this.length;
		var len = this.length;
		for(var i = 0; i < len; i++)
		{
			for(var j = i+1; j < len; j++)
			{
				if(this[i] == this[j]) count--;
			}
		}
		return count;
	},
	isSingle : function(arr)
	{
		var len = arr.length;
		for(var i = 0; i < len; i++)
		{
			for(var j = i+1; j < len; j++)
			{
				if(arr[i] == arr[j]) return false;
			}
		}
		return true;
	},
	/**
	 * 获得不重复的值
	 */
	getSingle : function()
	{
		var results = [];
		for(var v in this)
		{
			if(!results.contains(this[v])){
				results.append(this[v]);
			}
		}
		return results;
	},
	sum : function() 
	{
	    var temp = 0;
		for(var i in this)
		{
			if(!isNaN(this[i]))
				temp += this[i];
		}
		return temp;
	},
	include : function(arr)
	{
		for(var i in arr)
		{
			if(!this.contains(arr[i])) return false;
		}
		return true;
	},
	innercount : function(arr)
	{
		var count = 0;
		for(var i in arr)
		{
			if(this.contains(arr[i])) count++;
		}
		return count;
	},
	outcount : function(arr)
	{
		var count = 0;
		for(var i in arr)
		{
			if(arr.contains(this[i])) count++;
		}
		return count;
	},
	/**
	 * function printElt(element, index, array) {
	    print("[" + index + "] is " + element); // assumes print is already defined
	}
	[2, 5, 9].forEach(printElt);
	// Prints:
	// [0] is 2
	// [1] is 5
	// [2] is 9
	 */
	forEach : function(fn, bind)
	{
		for (var i = 0, j = this.length; i < j; i++) fn.call(bind, this[i], i, this);
	},
	each : function(iterator) 
	{
	    for (var i = 0, length = this.length; i < length; i++)
	    {
	    	if(typeof this[i] != "function")
	      		iterator(this[i]);
	      	else
	      		this[i].call(this);
	    }
	},
	every : function(fn, bind)
	{
		for (var i = 0, j = this.length; i < j; i++){
			if (!fn.call(bind, this[i], i, this)) return false;
		}
		return true;
	},
	some : function(fn, bind)
	{
		for (var i = 0, j = this.length; i < j; i++){
			if (fn.call(bind, this[i], i, this)) return true;
		}
		return false;
	},
	map : function(fn, bind)
	{
		var results = [];
		for (var i = 0, j = this.length; i < j; i++) results[i] = fn.call(bind, this[i], i, this);
		return results;
	},
	filter : function(fn, bind)
	{
		var results = [];
		for (var i = 0, j = this.length; i < j; i++){
			if (fn.call(bind, this[i], i, this)) results.push(this[i]);
		}
		return results;
	},
	toArray : function(index)
	{
		var results = [];
		for (var i = index, j = this.length; i < j; i++){
			results.push(this[i]);
		}
		return results; 
	},
	toString : function(sp)
	{
		var temp = sp || "";
		return this.join(temp); 
	},
	end : {}
	
});